
"""
NC141 判断字符串是否为回文串
https://www.nowcoder.com/practice/e297fdd8e9f543059b0b5f05f3a7f3b2?tpId=117&&tqId=37852&&companyId=239&rp=1&ru=/company/home/code/239&qru=/ta/job-code-high/question-ranking
"""

#
# 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
#
#
# @param str string字符串 待判断的字符串
# @return bool布尔型
#


class Solution:
    def method1(self, s: str) -> bool:
        """
        仅适用于python
        """
        if len(s) <= 1:
            return True

        return s == s[::-1]

    def method2(self, s: str) -> bool:
        """
        对撞指针
        """
        if len(s) <= 1:
            return True

        l, r = 0, len(s)-1
        while l <= r:
            if s[l] != s[r]:
                return False

            l += 1
            r -= 1

        return True

    def judge(self, s: str) -> bool:
        # write code here
        return self.method2(s)


def test():
    obj = Solution()
    s = "aaaa"
    res = obj.judge(s)
    print(res)


if __name__ == "__main__":
    test()
